package com.wl.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @program: treeHole
 * @author: 吴磊
 * @create: 2021-07-07 10:09
 */
public class Myproperties extends Properties {

    private static final long serialVersionUID = 1L;
    private static Myproperties myprop = null;

    private Myproperties() {
        InputStream is = this.getClass().getResourceAsStream("/db.properties");
        try {
            this.load(is);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                is.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    /**
     * 对外提供一个获取唯一实例的方法
     *
     * @return
     */
    public static Myproperties getMyProperties() {
        if (myprop == null) {
            myprop = new Myproperties();
        }
        return myprop;
    }
}
